package org.jeecg.modules.system.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.jeecg.modules.system.entity.ZkEquipmentMaintain;
import org.jeecg.modules.system.entity.ZkEquipmentMaintainDetail;

import java.util.List;
import java.util.Map;

/**
 * @Description: 设备保养表
 * @Author: jeecg-boot
 * @Date:   2024-04-28
 * @Version: V1.0
 */
public interface ZkEquipmentMaintainMapper extends BaseMapper<ZkEquipmentMaintain> {

    //设备保养根据当前登录人员和时间查询
    List<ZkEquipmentMaintain> queryPageListVo(Page<ZkEquipmentMaintain> page, @Param("id") String id);

    /**
     * 审批界面/保养（根据当前登录人和状态分页查询）
     * @param page     分页参数
     * @param id       当前登录人
     * @return
     */
    @Select("select * from zk_equipment_maintain_detail where aud_personnel_id=#{id} and personnel_status=1")
    IPage<ZkEquipmentMaintainDetail> queryZkEquipmentMaintainDetail(Page<ZkEquipmentMaintainDetail> page, @Param("Id") String id);

    /**
     * 发起界面/保养（根据当前登录人和状态分页查询）
     * @param page     分页参数
     * @param id       当前登录人
     * @return
     */
    @Select("select * from zk_equipment_maintain_detail where maintain_personnel_id=#{id} and personnel_status=1")
    IPage<ZkEquipmentMaintainDetail> queryZkEquipmentMaintainList(Page<ZkEquipmentMaintainDetail> page, @Param("Id") String id);

    /**
     * 抄送任务(保养)（根据当前登录人和状态将维修，保养，检修放在同一个分页查询中）
     */
    @Select("select * from zk_equipment_maintain_detail where cc_personnel_id=#{id} and if_cc=1")
    IPage<ZkEquipmentMaintainDetail> queryZkEquipmentMaintainCc(Page<ZkEquipmentMaintainDetail> page, @Param("Id") String id);

    /**
     * 抄送任务(保养)（根据当前登录人和状态将维修，保养，检修放在同一个分页查询中）
     */
    @Select("select * from zk_equipment_maintain")
    List<ZkEquipmentMaintain> queryZkEquipmentMaintain();

    /**
     * 保养柱状图PC端首页(根据保养周期统计数量)
     */
    @Select("select count(*) as countNum ,maintain_time as maintainTime from zk_equipment_maintain GROUP BY maintain_time")
    List<Map<Integer,Integer>> pcCount();

}
